package com.tanhua.server.controller;

import com.tanhua.server.service.VoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("peachblossom")
public class VoiceController {

    @Autowired
    private VoiceService voiceService;


    /**
     * 发送语音
     * @param voiceFile 语音文件
     * @return
     */
    @PostMapping
    public Object saveVoice(@RequestParam("soundFile") MultipartFile voiceFile) {

        return this.voiceService.saveVoice(voiceFile);
    }

    /**
     * 接收语音
     * @return 封装了语音信息,包括用户id,语音地址,剩余次数等
     */
    @GetMapping
    public Object receiveVoice() {

        return this.voiceService.receiveVoice();
    }

}
